package com.shujia.java.day4;

import java.util.Arrays;
import java.util.Scanner;

public class Demo4MaxAndMin {
    public static void main(String[] args) {

        int arr[] = {1, 2, 4, 5, 6, 7, 4, 3, 3, 5, 6, 7, 8, 42, 66};

        /**
         * 获取最大和最小的元素
         *
         *
         * Integer.MIN_VALUE  获取int类型的最大值
         */

        int max = 0;
        int min = Integer.MAX_VALUE;

        for (int i = 0; i < arr.length; i++) {
            if (arr[i] > max) {
                max = arr[i];
            }

            if (arr[i] < min) {
                min = arr[i];
            }
        }

        System.out.println("最大值：" + max);
        System.out.println("最小值：" + min);


    }
}
